<?php
	require('../Model/mysql.php');
	require('../host_config.php');
	$mysql = new MySQL();
	$link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
	
	if(isset($_POST['shopid'])) {
		$shopid = $mysql->real($_POST['shopid']);
		$sql = "SELECT `nickname`, `comments`, `rank` FROM `Comment` WHERE `shopid` = '$shopid'";
		$result = $mysql->query($sql, $link);
		
		while($row = mysql_fetch_row($result)) {
			
			$nickname = $row[0];
			$comment = $row[1];
			$rank = $row[2];
			$return[] = array(
						"nickname" => $nickname,
						"comments" => $comment,
						"rank" => $rank
					);
		}
		print(json_encode($return));
	}else {
		echo "<script language='javascript'>";
		echo "alert('You have no permission to read this page!');";
		echo "history.back();";
		echo "</script>";
		header("location:../login.php");
	}